Multivariate normal distribution

Probability density function
GaussianScatterPCA.png
Multivariate (bivariate) Gaussian distribution centered at (1,3) with a standard deviation of 3 in roughly the (0.878, 0.478) direction and of 1 in the orthogonal direction.
parameters: μRk — location
Σ ∈ Rk×k — covariance (nonnegative-definite matrix)
support: x ∈ span(Σ) ⊆ Rk
pdf: \frac{1}{(2\pi)^{k/2}|\Sigma|^{1/2}}\, e^{ -\frac{1}{2}(x-\mu)'\Sigma^{-1}(x-\mu) }
(pdf exists only for positive-definite Σ)
cdf: (no analytic expression)
mean: μ
mode: μ
variance: Σ
entropy: \ln\!\sqrt{(2\pi e)^k |\Sigma|}
mgf: \exp\!\Big( \mu't + \tfrac{1}{2} t'\Sigma t\Big)
cf: \exp\!\Big( i\mu't - \tfrac{1}{2} t'\Sigma t\Big)

In probability theory and statistics, the multivariate normal distribution or multivariate Gaussian distribution, is a generalization of the one-dimensional (univariate) normal distribution to higher dimensions. A random vector is said to be multivariate normally distributed if every linear combination of its components has a univariate normal distribution.

Contents

Notation and parametrization

The multivariate normal distribution of a k-dimensional random vector  X = [X_1, X_2, \ldots, X_k] can be written in the following notation:


    X\ \sim\ \mathcal{N}(\mu,\, \Sigma),

or to make it explicitly known that X is k-dimensional,


    X\ \sim\ \mathcal{N}_k(\mu,\, \Sigma).

with k-dimensional mean vector

 \mu = [ \operatorname{E}[X_1], \operatorname{E}[X_2], \ldots, \operatorname{E}[X_k]]

and k x k covariance matrix

 \Sigma = [\operatorname{Cov}[X_i, X_j]]_{i=1,2,\ldots,k; j=1,2,\ldots,k}

Definition

A random vector X = (X1, …, Xk)′ is said to have the multivariate normal distribution if it satisfies the following equivalent conditions [1]:

The covariance matrix is allowed to be singular (in which case the corresponding distribution has no density). This case arises frequently in statistics; for example, in the distribution of the vector of residuals in the ordinary least squares regression. Note also that the Xi are in general not independent; they can be seen as the result of applying the matrix A to a collection of independent Gaussian variables Z.

Bivariate case

In the 2-dimensional nonsingular case (k = rank(Σ) = 2), the probability density function of a vector [X Y]′ is


    f(x,y) =
      \frac{1}{2 \pi \sigma_x \sigma_y \sqrt{1-\rho^2}}
      \exp\left(
        -\frac{1}{2(1-\rho^2)}\left[
          \frac{(x-\mu_x)^2}{\sigma_x^2} +
          \frac{(y-\mu_y)^2}{\sigma_y^2} -
          \frac{2\rho(x-\mu_x)(y-\mu_y)}{\sigma_x \sigma_y}
        \right]
      \right),

where ρ is the correlation between X and Y. In this case,


    \mu = \begin{pmatrix} \mu_x \\ \mu_y \end{pmatrix}, \quad
    \Sigma = \begin{pmatrix} \sigma_x^2 & \rho \sigma_x \sigma_y \\
                             \rho \sigma_x \sigma_y  & \sigma_y^2 \end{pmatrix}.

In the bivariate case, we also have a theorem that makes the first equivalent condition for multivariate normality less restrictive: it is sufficient to verify that countably many distinct linear combinations of X and Y are normal in order to conclude that the vector [X Y]′ is bivariate normal.[2]

Properties

Cumulative distribution function

The cumulative distribution function (cdf) F(x) of a random vector X is defined as the probability that all components of X are less than or equal to the corresponding values in the vector x. Though there is no closed form for F(x), there are a number of algorithms that estimate it numerically. For example, see MVNDST under [2] (includes FORTRAN code) or [3] (includes MATLAB code).

Normally distributed and independent

If X and Y are normally distributed and independent, this implies they are "jointly normally distributed", i.e., the pair (XY) must have bivariate normal distribution. However, a pair of jointly normally distributed variables need not be independent.

Two normally distributed random variables need not be jointly bivariate normal

The fact that two random variables X and Y both have a normal distribution does not imply that the pair (XY) has a joint normal distribution. A simple example is one in which X has a normal distribution with expected value 0 and variance 1, and Y = X if |X| > c and Y = −X if |X| < c, where c is about 1.54. There are similar counterexamples for more than two random variables.

Conditional distributions

If \mu and \Sigma are partitioned as follows


\mu
=
\begin{bmatrix}
 \mu_1 \\
 \mu_2
\end{bmatrix}
\quad with sizes \begin{bmatrix} q \times 1 \\ (N-q) \times 1 \end{bmatrix}

\Sigma
=
\begin{bmatrix}
 \Sigma_{11} & \Sigma_{12} \\
 \Sigma_{21} & \Sigma_{22}
\end{bmatrix}
\quad with sizes \begin{bmatrix} q \times q & q \times (N-q) \\ (N-q) \times q & (N-q) \times (N-q) \end{bmatrix}

then the distribution of x_1 conditional on x_2=a is multivariate normal (X_1|X_2=a) \sim N(\bar{\mu}, \overline{\Sigma}) where


\bar{\mu}
=
\mu_1 + \Sigma_{12} \Sigma_{22}^{-1}
\left(
 a - \mu_2
\right)

and covariance matrix


\overline{\Sigma}
=
\Sigma_{11} - \Sigma_{12} \Sigma_{22}^{-1} \Sigma_{21}.

This matrix is the Schur complement of {\mathbf\Sigma_{22}} in {\mathbf\Sigma}. This means that to calculate the conditional covariance matrix, one inverts the overall covariance matrix, drops the rows and columns corresponding to the variables being conditioned upon, and then inverts back to get the conditional covariance matrix.

Note that knowing that x_2=a alters the variance, though the new variance does not depend on the specific value of a; perhaps more surprisingly, the mean is shifted by \Sigma_{12} \Sigma_{22}^{-1} \left(a - \mu_2 \right); compare this with the situation of not knowing the value of a, in which case x_1 would have distribution N_q \left(\mu_1, \Sigma_{11} \right).

The matrix \Sigma_{12} \Sigma_{22}^{-1} is known as the matrix of regression coefficients.

In the bivariate case the conditional distribution of Y given X is

Y|X=x \ \sim\ \mathcal{N}\left(\mu_Y+\frac{\sigma_Y}{\sigma_X}\rho(x-\mu_X),\, (1-\rho^2)\sigma_Y^2\right).

Bivariate conditional expectation

In the case


\begin{pmatrix}
 X_1 \\
 X_2
\end{pmatrix}  \sim \mathcal{N} \left( \begin{pmatrix}
 0 \\
 0
\end{pmatrix} , \begin{pmatrix}
 1 & \rho \\
 \rho & 1 
\end{pmatrix} \right)

then


E(X_1 | X_2 > z) = \rho { \phi(z) \over \Phi(-z) }

where this latter ratio is often called the inverse Mills ratio.

Marginal distributions

To obtain the marginal distribution over a subset of multivariate normal random variables, one only needs to drop the irrelevant variables (the variables that one wants to marginalize out) from the mean vector and the covariance matrix. The proof for this follows from the definitions of multivariate normal distributions and some advanced linear algebra [3].

Example

Let  X =[X_1, X_2, X_3] be multivariate normal random variables with mean vector  \mu = [\mu_1 \mu_2 \mu_3] and covariance matrix  \Sigma (Standard parametrization for multivariate normal distribution). Then the joint distribution of  X' = [X_1 X_3] is multivariate normal with mean vector  \mu' = [\mu_1 \mu_3] and covariance matrix  \Sigma' = 
\begin{bmatrix}
\Sigma_{11} & \Sigma_{13} \\
\Sigma_{31} & \Sigma_{33}
\end{bmatrix}

Affine transformation

If Y = c + B X \, is an affine transformation of X\ \sim \mathcal{N}(\mu, \Sigma), where c\, is an M \times 1 vector of constants and B\, is a constant M \times N matrix, then Y\, has a multivariate normal distribution with expected value c + B \mu \, and variance B \Sigma B^T \, i.e., Y \sim \mathcal{N} \left(c + B \mu, B \Sigma B^T\right). In particular, any subset of the X_i\, has a marginal distribution that is also multivariate normal. To see this, consider the following example: to extract the subset (X_1, X_2, X_4)^T \,, use


B
=
\begin{bmatrix}
 1 & 0 & 0 & 0 & 0 & \ldots & 0 \\
 0 & 1 & 0 & 0 & 0 & \ldots & 0 \\
 0 & 0 & 0 & 1 & 0 & \ldots & 0
\end{bmatrix}

which extracts the desired elements directly.

Another corollary is that the distribution of Z=b\cdot X, where b is a constant vector of the same length as X and the dot indicates a vector product, is univariate Gaussian with Z\sim\mathcal{N}\left(b\cdot\mu, b^T\Sigma b\right). This result follows by using


B=\begin{bmatrix}
b_1    & b_2    & \ldots & b_n    \\
0      & 0      & \ldots & 0      \\
\vdots & \vdots & \ddots & \vdots \\
0      & 0      & \ldots & 0
\end{bmatrix}

and considering only the first component of the product (the first row of B is the vector b). Observe how the positive-definiteness of \Sigma implies that the variance of the dot product must be positive.

An affine transformation of X such as 2X is not the same as the sum of two independent realisations of X.

Geometric interpretation

The equidensity contours of a non-singular multivariate normal distribution are ellipsoids (i.e. linear transformations of hyperspheres) centered at the mean[4]. The directions of the principal axes of the ellipsoids are given by the eigenvectors of the covariance matrix \Sigma. The squared relative lengths of the principal axes are given by the corresponding eigenvalues.

If \Sigma=U\Lambda U^T=U\Lambda^{1/2}(U\Lambda^{1/2})^T is an eigendecomposition where the columns of U are unit eigenvectors and \Lambda is a diagonal matrix of the eigenvalues, then we have

X\ \sim N(\mu, \Sigma) \iff X\ \sim \mu+U\Lambda^{1/2}N(0, I) \iff X\ \sim \mu+UN(0, \Lambda).

Moreover, U can be chosen to be a rotation matrix, as inverting an axis does not have any effect on N(0, \Lambda), but inverting a column changes the sign of U's determinant. The distribution N(\mu, \Sigma) is in effect N(0, I) scaled by \Lambda^{1/2}, rotated by U and translated by \mu.

Conversely, any choice of \mu, full rank matrix U, and positive diagonal entries \Lambda_i yields a non-singular multivariate normal distribution. If any \Lambda_i is zero and U is square, the resulting covariance matrix U\Lambda U^T is singular. Geometrically this means that every contour ellipsoid is infinitely thin and has zero volume in n-dimensional space, as at least one of the principal axes has length of zero.

Correlations and independence

In general, random variables may be uncorrelated but highly dependent. But if a random vector has a multivariate normal distribution then any two or more of its components that are uncorrelated are independent. This implies that any two or more of its components that are pairwise independent are independent.

But it is not true that two random variables that are (separately, marginally) normally distributed and uncorrelated are independent. Two random variables that are normally distributed may fail to be jointly normally distributed, i.e., the vector whose components they are may fail to have a multivariate normal distribution. For an example of two normally distributed random variables that are uncorrelated but not independent, see normally distributed and uncorrelated does not imply independent.

Higher moments

The kth-order moments of X are defined by


\mu _{1,\dots,N}(X)\ \stackrel{\mathrm{def}}{=}\  \mu _{r_{1},\dots,r_{N}}(X)\ \stackrel{\mathrm{def}}{=}\  E\left[
\prod\limits_{j=1}^{N}X_j^{r_{j}}\right]

where r_1 +r_2 + \cdots + r_N =k.

The central k-order central moments are given as follows

(a) If k is odd, \mu _{1,\dots,N}(X-\mu )=0.

(b) If k is even with k=2\lambda, then


\mu _{1,\dots,2\lambda }(X-\mu )=\sum \left( \sigma _{ij}\sigma _{k\ell}\cdots\sigma _{XZ}\right)

where the sum is taken over all allocations of the set \left\{ 1,\dots,2\lambda
\right\} into \lambda (unordered) pairs. That is, if you have a kth ({}=2\lambda=6) central moment, you will be summing the products of \lambda=3 covariances (the -\mu notation has been dropped in the interests of parsimony):

\begin{align}
& {} E[X_1 X_2 X_3 X_4 X_5 X_6] \\
&{} = E[X_1 X_2 ]E[X_3 X_4 ]E[X_5 X_6 ] + E[X_1 X_2 ]E[X_3 X_5 ]E[X_4 X_6] + E[X_1 X_2 ]E[X_3 X_6 ]E[X_4 X_5] \\
&{} + E[X_1 X_3 ]E[X_2 X_4 ]E[X_5 X_6 ] + E[X_1 X_3 ]E[X_2 X_5 ]E[X_4 X_6 ] + E[X_1 X_3]E[X_2 X_6]E[X_4 X_5] \\
&+ E[X_1 X_4]E[X_2 X_3]E[X_5 X_6]+E[X_1 X_4]E[X_2 X_5]E[X_3 X_6]+E[X_1 X_4]E[X_2 X_6]E[X_3 X_5] \\
& + E[X_1 X_5]E[X_2 X_3]E[X_4 X_6]+E[X_1 X_5]E[X_2 X_4]E[X_3 X_6]+E[X_1 X_5]E[X_2 X_6]E[X_3 X_4] \\
& + E[X_1 X_6]E[X_2 X_3]E[X_4 X_5 ] + E[X_1 X_6]E[X_2 X_4 ]E[X_3 X_5] + E[X_1 X_6]E[X_2 X_5]E[X_3 X_4].
\end{align}

This yields (2\lambda -1)!/(2^{\lambda -1}(\lambda -1)!) terms in the sum (15 in the above case), each being the product of \lambda (in this case 3) covariances. For fourth order moments (four variables) there are three terms. For sixth-order moments there are 3 × 5 = 15 terms, and for eighth-order moments there are 3 × 5 × 7 = 105 terms.

The covariances are then determined by replacing the terms of the list \left[ 1,\dots,2\lambda \right] by the corresponding terms of the list consisting of r_1 ones, then r_2 twos, etc... To illustrate this, examine the following 4th-order central moment case:

E\left[ X_i^4\right] = 3\sigma _{ii}^2
E\left[ X_i^3 X_j\right] = 3\sigma _{ii} \sigma _{ij}
E\left[ X_i^2 X_j^2\right] = \sigma _{ii}\sigma_{jj}+2\left( \sigma _{ij}\right) ^2
E\left[ X_i^2X_jX_k\right] = \sigma _{ii}\sigma _{jk}+2\sigma _{ij}\sigma _{ik}
E\left[ X_i X_j X_k X_n\right] = \sigma _{ij}\sigma _{kn}+\sigma _{ik}\sigma _{jn}+\sigma _{in}\sigma _{jk}.

where  \sigma_{ij} is the covariance of  X_i and  X_j. The idea with the above method is you first find the general case for a kth moment where you have k different X variables - E\left[ X_i X_j X_k X_n\right] and then you can simplify this accordingly. Say, you have E\left[ X_i^2 X_k X_n\right] then you simply let X_i = X_j and realise that \sigma_{ii}=\sigma_i^2.

Kullback–Leibler divergence

The Kullback–Leibler divergence from \mathcal{N}_0(\mu_0, \Sigma_0) to \mathcal{N}_1(\mu_1, \Sigma_1), for non-singular matrices \Sigma_0 and \Sigma_1, is:


D_\text{KL}(\mathcal{N}_0 \| \mathcal{N}_1) = { 1 \over 2 } \left( \log_e \left( { \det \Sigma_1 \over \det \Sigma_0 } \right) + \mathrm{tr} \left( \Sigma_1^{-1} \Sigma_0 \right) + \left( \mu_1 - \mu_0\right)^\top \Sigma_1^{-1} ( \mu_1 - \mu_0 ) - N \right).
[5]

The logarithm must be taken to base e since the two terms following the logarithm are themselves base-e logarithms of expressions that are either factors of the density function or otherwise arise naturally. The equation therefore gives a result measured in nats. Dividing the entire expression above by loge 2 yields the divergence in bits.

Estimation of parameters

The derivation of the maximum-likelihood estimator of the covariance matrix of a multivariate normal distribution is perhaps surprisingly subtle and elegant. See estimation of covariance matrices.

In short, the probability density function (pdf) of an N-dimensional multivariate normal is

f(x)=(2 \pi)^{-N/2} \det(\Sigma)^{-1/2} \exp\left(-{1 \over 2} (x-\mu)^T \Sigma^{-1} (x-\mu)\right)

and the ML estimator of the covariance matrix from a sample of n observations is

\widehat\Sigma = {1 \over n}\sum_{i=1}^n (X_i-\overline{X})(X_i-\overline{X})^T

which is simply the sample covariance matrix. This is a biased estimator whose expectation is

E[\widehat\Sigma] = {n-1 \over n}\Sigma.

An unbiased sample covariance is

\widehat\Sigma = {1 \over n-1}\sum_{i=1}^n (X_i-\overline{X})(X_i-\overline{X})^T.

The Fisher information matrix for estimating the parameters of a multivariate normal distribution has a closed form expression. This can be used, for example, to compute the Cramer-Rao bound for parameter estimation in this setting. See Fisher information#Multivariate normal distribution for more details.

Entropy

The differential entropy of the multivariate normal distribution is [6]


\begin{align}
h\left(f\right) & = -\int_{-\infty}^\infty \int_{-\infty}^\infty \cdots\int_{-\infty}^\infty f(x) \ln f(x)\,dx \\
& = \frac12 \left(N+N\ln\left(2\pi\right) + \ln\left| \Sigma \right|\right) \\
& =\frac{1}{2}\ln\{(2\pi e)^N \left| \Sigma \right|\}
\end{align}

where \left| \Sigma \right| is the determinant of the covariance matrix \Sigma.

Multivariate normality tests

Multivariate normality tests check a given set of data for similarity to the multivariate normal distribution. The null hypothesis is that the data set is similar to the normal distribution, therefore a sufficiently small p-value indicates non-normal data. Multivariate normality tests include the Cox-Small test [7] and Smith and Jain's adaptation [8] of the Friedman-Rafsky test.[9]

Drawing values from the distribution

A widely used method for drawing a random vector X from the N-dimensional multivariate normal distribution with mean vector \mu and covariance matrix \Sigma (required to be symmetric and positive-definite) works as follows:

  1. Find any matrix A such that A\,A^T = \Sigma. Often this is a Cholesky decomposition, though a square root of \Sigma would also suffice.
  2. Let Z=(z_1,\dots,z_N)^T be a vector whose components are N independent standard normal variates (which can be generated, for example, by using the Box-Muller transform).
  3. Let X \, be \mu + AZ \,. This has the desired distribution due to the affine transformation property.

See also

References

  1. Gut, Allan: An Intermediate Course in Probability, 2009, chapter 5
  2. Hamedani & Tata (1975)
  3. The formal proof for marginal distribution is shown here http://fourier.eng.hmc.edu/e161/lectures/gaussianprocess/node7.html
  4. Nikolaus Hansen. "The CMA Evolution Strategy: A Tutorial" (PDF). http://www.bionik.tu-berlin.de/user/niko/cmatutorial.pdf. 
  5. Penny & Roberts, PARG-00-12, (2000) [1]. pp. 18
  6. Gokhale, DV; NA Ahmed, BC Res, NJ Piscataway (May 1989). "Entropy Expressions and Their Estimators for Multivariate Distributions". Information Theory, IEEE Transactions on 35 (3): 688–692. doi:10.1109/18.30996. 
  7. Cox, D. R.; N. J. H. Small (August 1978). "Testing multivariate normality". Biometrika 65 (2): 263–272. doi:10.1093/biomet/65.2.263. 
  8. Smith, Stephen P.; Anil K. Jain (September 1988). "A test to determine the multivariate normality of a dataset". IEEE Transactions on Pattern Analysis and Machine Intelligence 10 (5): 757–761. doi:10.1109/34.6789. 
  9. Friedman, J. H. and Rafsky, L. C. (1979) "Multivariate generalizations of the Wald-Wolfowitz and Smirnov two sample tests". Annals of Statistics, 7, 697–717.

Literature

Hamedani, G. G.; Tata, M. N. (1975). "On the determination of the bivariate normal distribution from distributions of linear combinations of the variables". The American Mathematical Monthly (The American Mathematical Monthly, Vol. 82, No. 9) 82 (9): 913–915. doi:10.2307/2318494. JSTOR 2318494. http://jstor.org/stable/2318494.